<?php
session_start();
if(!isset($_SESSION['id'])){
    header('Location: login.php');
    exit;
}
?>
<!DOCTYPE html>
<html lang="en" class="no-js">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
		<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
		<title>::: SOS UNITAU -- Sistema de ordem de serviço</title>
		
		<link rel="shortcut icon" href="img/logo.jpg">
		<link rel="stylesheet" type="text/css" href="css/normalize.css" />
		<link rel="stylesheet" type="text/css" href="css/demo.css" />
		<link rel="stylesheet" type="text/css" href="css/icons.css" />
		<link rel="stylesheet" type="text/css" href="css/style2.css" />
        <link rel="stylesheet" type="text/css" href="css/StylePage.css" />
        <link rel="stylesheet" type="text/css" href="css/default.css" />
        <link rel="stylesheet" type="text/css" href="css/component.css" />
          <script src="js/jquery.min.js"></script>
        <script type="text/javascript" src="js/jquery1.6.min.js"></script>
        <script src="js/jquery.maskedinput-1.3.min.js"></script>
         <script type="text/javascript"><!-- PARA NAO CONFLITAR -->
		var $JQuery = jQuery.noConflict();
		</script>
        
        <script>
		 jQuery(function($){
	     
                              $(".cep").mask("99.999-999");
			  
		});
			
		</script>
        
         
        <script>
            $(document).ready(function () {
                $('#novoCep').click(function () {
                    
                    var cep = $('#txtCEP').val();
                    var endereco = $('#txtEndereco').val();
                    var bairro = $('#txtBairro').val();
                    var cidade = $('#txtCidade').val();
                    var uf = $('#txtUF').val();
                    
                    $.post("../funcoes/novo_logradouro.php", {cep: cep, endereco: endereco, bairro: bairro, cidade: cidade,
                        uf: uf}, function (data) {
                        alert(data);
                        if (data == 'Cadastrado com Sucesso') {

                            window.opener.document.getElementById('txtCEP').value = cep;
                            window.opener.document.getElementById('txtEndereco').value = endereco;
                            window.opener.document.getElementById('txtBairro').value = bairro;
                            window.opener.document.getElementById('txtCidade').value = cidade;
                            window.opener.document.getElementById('txtUF').value = uf;
                            
                            window.self.close();
                            
                        }
                    });
                });
            });
        </script>
        
</head>
<body style="overflow-x: hidden">
	 <form name="adicionarCEP" id="adicionarCEP" method="post" action="" class="style-form">
            	
                <fieldset style="width:30px;">
                	<legend>Informações do logradouro </legend>
                    <table width="800px" class="table-form">
            	<tr>
            			<td> <label for="txtCEP"> CEP: </label> </td>
            			<td> <input name="txtCEP" id="txtCEP" type="text" class="cep" required /></td>
            		</tr>
                    	<td> <label for="txtEndereco"> Endereço: </label></td>
                        <td> <textarea name="txtEndereco" id="txtEndereco" placeholder="Informe um endereço válido" ></textarea></td>
            		</tr>
                    <tr>
            			<td> <label for="txtBairro"> Bairro: </label> </td>
            			<td> <input name="txtBairro" id="txtBairro" type="text" required placeholder="Ex: Maria Augusta" /></td>
            		</tr>
                      <tr>
            			<td> <label for="txtCidade"> Cidade: </label> </td>
            			<td> <input name="txtCidade" id="txtCidade" type="text" required placeholder="Ex: Taubaté"/></td>
            		</tr>
                    <tr>
            			<td> <label for="txtUF"> UF: </label> </td>
            			<td> <input name="txtUF" id="txtUF" type="text" style="width:50px" maxlength="2" /></td>
                    </tr>
                    
            	</table>
                        <input type="button" value="Gravar" id="novoCep" style="display:inline-block; margin-left:50%; margin-top:3%;" class="botao" />
                        <input type="button" value="Cancelar" style="margin-left:5%;" onClick="javascript:c=window.confirm('Deseja Realmente cancelar?');if(c==true){self.close();}else{}" class="botao"/>    
                	</fieldset>

		</form>


</body>
</html>